<template>
  <div class="flh_datakb">
    <div class="mainView">
      <mainTitle :hideLogo="false">
        <span slot="title" class="title">工作量数据看板</span>
      </mainTitle>
      <color-row-tab v-model="titleArr" class="colorRowTab"></color-row-tab>
      <div class="line"></div>
      <mainTitle :hideLogo="false">
        <div slot="title" class="subTitle">工作量排名TOP10
          <div class="tabCon">
            <div @click="onTab(19012)" class="tab" :class="activeTab === 19012 ? 'activeTab':''">区域</div>
            <div @click="onTab(19010)" class="tab" :class="activeTab === 19010? 'activeTab':''">门店</div>
            <div @click="onTab(19011)" class="tab" :class="activeTab === 19011? 'activeTab':''">经纪人</div>
          </div>
        </div>
      </mainTitle>
      <bar-chart v-model="barData" :chartStyle="'width:65%;min-height:500px;'" :option="barChartOption"></bar-chart>
      <div class="rightView">
        <div class="list">
          <div class="item">
            <img src="/static/img/flh/news/fangyuan@2x.png" /><span style="color:#5EECA8">房源跟进率</span><span style="color: #5EECA8">{{rightData.housingFollowUpRatio}}%</span>
          </div>
          <div class="item">
            <img src="/static/img/flh/news/keyuan_1@2x.png" /><span style="color:#85E081">客源跟进率</span><span style="color: #85E081">{{rightData.touristsFollowUpRatio}}%</span>
          </div>
          <div class="item">
            <img src="/static/img/flh/news/shikanlv@2x.png" /><span style="color:#85E081">实勘率</span><span style="color: #ACD65E">{{rightData.realProspectingRatio}}%</span>
          </div>
          <div class="item">
            <img src="/static/img/flh/news/daikanlv@2x.png" /><span style="color:#CFCD44">带看率</span><span style="color: #CFCD44">{{rightData.takeALookRatio}}%</span>
          </div>
          <div class="item">
            <img src="/static/img/flh/news/yaoshi@2x.png" /><span style="color:#FDC409">钥匙率</span><span style="color: #FDC409">{{rightData.keyNumRatio}}%</span>
          </div>
          <div class="line"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import mainTitle from "@/components/flh/dataKanban/mainTitle";
import colorRowTab from "./components/colorRowTab";
import { GetWorkloadRanking, GetFLHWorkloadData } from "@/api/flh/home";
export default {
  components: {
    mainTitle,
    colorRowTab
  },
  data() {
    return {
      activeTab: 19012,
      titleArr: [],
      barData: [],
      rightData: {
        housingFollowUpRatio: 0,
        touristsFollowUpRatio: 0,
        realProspectingRatio: 0,
        takeALookRatio: 0,
        keyNumRatio: 0
      },
      barChartOption: {
        openDataZoom: true,
        showLabel: false,
        grid: {
          left: "5%"
        },
        xAxis: {
          axisLine: {
            show: true,
            lineStyle: {
              color: "black"
            }
          },
          axisLabel: {
            rotate: 0,
            rich: {
              value: {
                color: "#E5E5E5"
              }
            }
          },
          axisTick: {
            show: false
          }
        },
        yAxis: {
          // max: 5000,
          splitLine: {
            show: true,
            lineStyle: {
              color: "black",
              width: 1,
              type: "solid"
            }
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "black"
            }
          },
          axisLabel: {
            color: "#E5E5E5"
          },
          axisTick: {
            show: false
          }
        },
        startColor: "rgb(50, 182, 132)",
        endColor: "rgba(50, 182, 132,0.7)",
        barWidth: 50
      }
    };
  },
  mounted() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.fetchLineData(19012);
      this.fetchRightData();
    },
    async fetchRightData() {
      var params = {
        cityId: 36001
      };
      var res = await GetFLHWorkloadData(params);
      if (res.data.code === "0") {
        var rightData = res.data.result;
        this.$set(this, "rightData", rightData);
        var arr = [
          {
            dataArr: [
              {
                name: "房源跟进",
                value: rightData.housingFollowUp
              },
              {
                name: "客源跟进",
                value: rightData.touristsFollowUp
              }
            ],
            unit: ""
          },
          {
            dataArr: [
              {
                name: "房源实勘",
                value: rightData.realProspecting
              }
            ],
            unit: ""
          },
          {
            dataArr: [
              {
                name: "客户带看",
                value: rightData.takeALook
              }
            ],
            unit: ""
          },
          {
            dataArr: [
              {
                name: "钥匙",
                value: rightData.keyNum
              }
            ],
            unit: ""
          }
        ];
        this.$set(this, "titleArr", arr);
      }
    },
    async fetchLineData(val) {
      var params = {
        timeType: "3011",
        cityId: 36001,
        queryType: val
      };
      var res = await GetWorkloadRanking(params);
      if (res.data.code === "0") {
        var barData = res.data.result;
        this.$set(this, "barData", barData);
      }
    },
    onTab(val) {
      this.fetchLineData(val);
      this.$set(this, "activeTab", val);
    }
  }
};
</script>

<style lang="scss" scoped>
@import "../../../../../styles/base/_parameters";
.colorRowTab {
  margin-top: 100px;
  // width: 70%;
}

.flh_datakb {
  @include absoluteAllSides;
  overflow: hidden;
  .mainView {
    @include absoluteAllSides(40, 40, 40, 100);
    .title {
      font-size: 48px;
      font-weight: bold;
    }
    .line {
      height: 50px;
    }
    .subTitle {
      font-size: 30px;
      font-weight: normal;
    }
    .rightView {
      position: absolute;
      right: 300px;
      top: 200px;
      .list {
        position: relative;
        .item {
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-top: 80px;
          width: 230px;
          img {
            width: 40px;
            height: 40px;
          }
          span:nth-of-type(1) {
            margin-left: 20px;
            color: white;
            font-size: 22px;
            text-align: left;
            width: 110px;
          }
          span:nth-of-type(2) {
            width: 60px;
            text-align: right;
            color: green;
            line-height: 0;
            margin-top: 6px;
            @include din(32px);
          }
        }
        .line {
          width: 3px;
          height: 470px;
          background: linear-gradient(#55eda7, #fdc409);
          z-index: -1;
          @include absoluteTopLeft(10px, 18px);
        }
      }
    }
  }
}

.tabCon {
  display: inline-flex;
  margin-left: 630px;
  justify-content: space-between;
  align-items: center;
  width: 280px;
  font-size: 22px;
  .tab {
    padding: 2px 15px;
    font-size: 22px;
    border-radius: 18px;
    cursor: pointer;
  }
  .activeTab {
    background: #55eda7;
    color: black;
  }
}
</style>